Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Google Scripts "Utilities.formatDate" does nothing with the time zone parameter

This 2 lines generate the same output:

Logger.log(Utilities.formatDate(new Date(), "ET", "yyyy-MM-dd'T'HH:mm:ss'Z'"));
Logger.log(Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss'Z'"));

Output:

2:20:37 PM Info -> 2022-01-26T19:20:37Z
2:20:37 PM Info -> 2022-01-26T19:20:37Z

Doesn't matter the input, is always converting the date to UTC (probably), this makes impossible to print the correct date and time.

What is the correct way to format a date-time in Google Scripts?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

"ET" is not an accepted time zone name.

For that you would use 'America/New_York'.

Apps Script's documentation doesn't call that out, which can be frustrating to non-developers. Here is the list of all the timeZone ids

Also, by putting the '' around the Z, it treats it as a string and just returns the date with a Z. I know that is what is in the example on the apps script page, but it is wrong.

Try this:

Logger.log(Utilities.formatDate(new Date(), "America/New_York", "yyyy-MM-dd'T'HH:mm:ss z"));
Logger.log(Utilities.formatDate(new Date(), "America/New_York", "yyyy-MM-dd'T'HH:mm:ss Z"));
Logger.log(Utilities.formatDate(new Date(), "America/Los_Angeles", "yyyy-MM-dd'T'HH:mm:ss z"));
Logger.log(Utilities.formatDate(new Date(), "America/Los_Angeles", "yyyy-MM-dd'T'HH:mm:ss Z"));
Logger.log(Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd'T'HH:mm:ss Z"));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!